package com.cheng.service.transit.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cheng.dao.transit.SigninfoDao;
import com.cheng.dao.transit.TransitinfoDao;
import com.cheng.domain.transit.SignInfo;
import com.cheng.domain.transit.TransitInfo;
import com.cheng.index.takedelivery.WayBillIndexDao;
import com.cheng.service.transit.SigninfoService;
@Service
@Transactional
public class SigninfoServiceImpl implements SigninfoService {

	@Autowired
	private SigninfoDao signinfoDao;
	@Autowired
	private TransitinfoDao transitInfoDao;
	@Autowired
	private WayBillIndexDao wayBillIndexDao;
	@Override
	public void save(SignInfo model, Integer transitinfoid) {
		signinfoDao.save(model);
		TransitInfo transitInfo = transitInfoDao.findOne(transitinfoid);
		transitInfo.setSignInfo(model);
		if ("正常".equals(model.getSignType())) {
			transitInfo.setStatus("正常签收");
			transitInfo.getWayBill().setSignStatus(3);
		}else{
			transitInfo.setStatus("异常");
			transitInfo.getWayBill().setSignStatus(4);
		}
		//更改索引
		wayBillIndexDao.save(transitInfo.getWayBill());
	}

}
